﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


public class TweenActionSpawn:TweenActionBase
{
    private TweenActionBase[] actions;
    public TweenActionSpawn(TweenActionBase[] actions)
    {
        this.actions = actions;
        float max = -1;
        for(int i=0;i<actions.Count();i++)
        {
            if(max<actions[i].totalTime)
            {
                max = actions[i].totalTime;
            }
        }
        totalTime = max;
    }
    public override void OnStart()
    {
        for (int i = 0; i < actions.Count(); i++)
        {
            actions[i].OnStart();
        }
    }
    public override void OnUpdate(float schedule) {

        for(int i=0;i<actions.Count();i++)
        {
            TweenActionBase curAction = actions[i];
            float curSchedule;
            if (curAction.totalTime > 0)
                curSchedule = Math.Min(1, schedule*totalTime / curAction.totalTime);
            else
                curSchedule = 1;
            actions[i].OnUpdate(curSchedule);
        }

    }
}

